
module dwt.internal.win32.winapi;

private import dwt.internal.win32.wintypes;

alias HANDLE HPAINTBUFFER;

extern (Windows){
HRESULT AssocQueryStringA(ASSOCF flags, int str, LPCSTR pszAssoc, LPCSTR pszExtra, LPSTR pszOut, DWORD *pcchOut);
HRESULT AssocQueryStringW(ASSOCF flags, int str, LPCWSTR pszAssoc, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut);
int AddFontResourceExA(char* lpszFilename, int fl, void* pdv);
int AddFontResourceExW(wchar* lpszFilename, int fl, void* pdv);

BOOL AlphaBlend(
  HDC hdcDest,                 // handle to destination DC
  int nXOriginDest,            // x-coord of upper-left corner
  int nYOriginDest,            // y-coord of upper-left corner
  int nWidthDest,              // destination width
  int nHeightDest,             // destination height
  HDC hdcSrc,                  // handle to source DC
  int nXOriginSrc,             // x-coord of upper-left corner
  int nYOriginSrc,             // y-coord of upper-left corner
  int nWidthSrc,               // source width
  int nHeightSrc,              // source height
  BLENDFUNCTION blendFunction  // alpha-blending function
);
BOOL TransparentBlt(
  HDC hdcDest,        // handle to destination DC
  int nXOriginDest,   // x-coord of destination upper-left corner
  int nYOriginDest,   // y-coord of destination upper-left corner
  int nWidthDest,     // width of destination rectangle
  int hHeightDest,    // height of destination rectangle
  HDC hdcSrc,         // handle to source DC
  int nXOriginSrc,    // x-coord of source upper-left corner
  int nYOriginSrc,    // y-coord of source upper-left corner
  int nWidthSrc,      // width of source rectangle
  int nHeightSrc,     // height of source rectangle
  UINT crTransparent  // color to make transparent
);
int IIDFromString (wchar* lpsz, byte* lpiid);
HRESULT ScriptJustify(
  SCRIPT_VISATTR* psva,
  int* piAdvance,
  int cGlyphs,
  int iDx,
  int iMinKashida,
  int* piJustify
);

HRESULT ScriptRecordDigitSubstitution(
  LCID Locale,
  SCRIPT_DIGITSUBSTITUTE* psds
);
HRESULT ScriptApplyDigitSubstitution(
  SCRIPT_DIGITSUBSTITUTE* psds,
  SCRIPT_CONTROL* psc,
  SCRIPT_STATE* pss
);

// UxTheme.dll
BOOL IsAppThemed();

HRESULT DrawThemeBackground(
    HTHEME hTheme,
    HDC hdc,
    int iPartId,
    int iStateId,
    RECT *pRect,
    RECT *pClipRect
);
HRESULT DrawThemeEdge(
    HTHEME hTheme,
    HDC hdc,
    int iPartId,
    int iStateId,
    LPCRECT pDestRect,
    UINT uEdge,
    UINT uFlags,
    LPRECT pContentRect
);
HRESULT DrawThemeIcon(
    HTHEME hTheme,
    HDC hdc,
    int iPartId,
    int iStateId,
    LPCRECT pRect,
    HIMAGELIST himl,
    int iImageIndex
);
HRESULT DrawThemeParentBackground(
    HWND hwnd,
    HDC hdc,
    RECT *prc
);
HRESULT DrawThemeText(
    HTHEME hTheme,
    HDC hdc,
    int iPartId,
    int iStateId,
    LPCWSTR pszText,
    int iCharCount,
    DWORD dwTextFlags,
    DWORD dwTextFlags2,
    LPCRECT pRect
);

HTHEME OpenThemeData(
    HWND hwnd,
    LPCWSTR pszClassList
);
HRESULT BufferedPaintInit();
HRESULT CloseThemeData(
    HTHEME hTheme
);
HRESULT BufferedPaintUnInit();
//BOOL IsHungAppWindow(
//    HWND hWnd
//);
HPAINTBUFFER BeginBufferedPaint(
    HDC hdcTarget,
    RECT *prcTarget,
    uint/+BP_BUFFERFORMAT+/ dwFormat,
    void*/+BP_PAINTPARAMS+/ pPaintParams,
    HDC *phdc
);
HRESULT EndBufferedPaint(
    HPAINTBUFFER hBufferedPaint,
    BOOL fUpdateTarget
);


HRESULT GetThemeTextExtent(
    HTHEME hTheme,
    HDC hdc,
    int iPartId,
    int iStateId,
    LPCWSTR pszText,
    int iCharCount,
    DWORD dwTextFlags,
    LPCRECT pBoundingRect,
    LPRECT pExtentRect
);
HRESULT SetWindowTheme(
    HWND hwnd,
    LPCWSTR pszSubAppName,
    LPCWSTR pszSubIdList
);

//Kernel32.lib
//LANGID GetSystemDefaultUILanguage();

// Macro from winnt.h/windows.h
WORD PRIMARYLANGID(
  WORD lgid
);

//Gdi32.lib
int IntersectClipRect(
  HDC hdc,         // handle to DC
  int nLeftRect,   // x-coord of upper-left corner
  int nTopRect,    // y-coord of upper-left corner
  int nRightRect,  // x-coord of lower-right corner
  int nBottomRect  // y-coord of lower-right corner
);

LRESULT CoCreateInstance(
    byte* rclsid, void* pUnkOuter, int dwClsContext, byte* riid, void* ppv
);
/+
// kernel32 winxp/vista
version(ANSI){
HANDLE CreateActCtxA(
  ACTCTXA* pActCtx
);
}
else{
HANDLE CreateActCtxW(
  ACTCTXW* pActCtx
);
}
BOOL ActivateActCtx(
  HACTCTX hActCtx,
  uint* lpCookie
);
+/
}


extern(Windows){

BOOL EnumSystemLanguageGroupsW(

	LANGUAGEGROUP_ENUMPROC pLangGroupEnumProc, // callback function
	DWORD dwFlags,                             // language groups
	LONG_PTR  lParam                           // callback parameter
); 

LPITEMIDLIST SHBrowseForFolderW(          
	BROWSEINFOW* lpbi
); 

BOOL SHGetPathFromIDListW(          
	LPCITEMIDLIST pidl,
    LPWSTR pszPath
); 

BOOL ShellExecuteExW(          
	LPSHELLEXECUTEINFOW lpExecInfo
); 

BOOL Shell_NotifyIconW( 
	DWORD dwMessage,
    PNOTIFYICONDATAW lpdata
); 

BOOL EnumSystemLanguageGroupsA(
	LANGUAGEGROUP_ENUMPROC pLangGroupEnumProc, // callback function
	DWORD dwFlags,                             // language groups
	LONG_PTR  lParam                           // callback parameter
); 

UINT ExtractIconExA(
	LPCSTR lpszFile,
	int nIconIndex,
	HICON *phiconLarge,
	HICON *phiconSmall,
	UINT nIcons
); 

UINT ExtractIconExW(
	LPCWSTR lpszFile,
	int nIconIndex,
	HICON *phiconLarge,
	HICON *phiconSmall,
	UINT nIcons
); 

BOOL GetComboBoxInfo(
	HWND hwndCombo,
    PCOMBOBOXINFO pcbi
); 

BOOL GetGUIThreadInfo(
	DWORD idThread,
	LPGUITHREADINFO lpgui
); 

DWORD GetLayout(
	HDC hdc      // handle to DC
); 

BOOL GetMenuBarInfo(
	HWND hwnd,
    LONG idObject,
    LONG idItem,
    PMENUBARINFO pmbi
); 

BOOL GetMenuInfo(          
	HMENU hmenu,
    LPCMENUINFO lpcmi
); 

BOOL GetMonitorInfoW(
	HMONITOR hMonitor,  // handle to display monitor
	LPMONITORINFO lpmi  // pointer to display monitor information
); 

int GetRandomRgn(
	HDC  hdc,    // handle to DC
	HRGN hrgn,   // handle to region
	INT  iNum    // must be SYSRGN
); 

BOOL GradientFill(
	HDC hdc,
	PTRIVERTEX pVertex,
	DWORD dwNumVertex,
	PVOID pMesh,
	DWORD dwNumMesh,
	DWORD dwMode
); 

HIMC ImmAssociateContext(
	HWND hWnd,
	HIMC hIMC
); 

int ImmDestroyContext(HIMC hIMC ); 

BOOL ImmGetCompositionFontA(
	HIMC hIMC,
	LPLOGFONTA lplf
); 

BOOL ImmGetCompositionFontW(
	HIMC hIMC,
	LOGFONTW* lplf
); 

LONG ImmGetCompositionStringA(
	HIMC hIMC,      
	DWORD dwIndex,  
	LPVOID lpBuf,   
	DWORD dwBufLen  
); 

LONG ImmGetCompositionStringW(
	HIMC hIMC,      
	DWORD dwIndex,  
	LPVOID lpBuf,   
	DWORD dwBufLen  
); 

HIMC ImmGetContext(
	HWND hWnd
); 

BOOL ImmGetConversionStatus(
	HIMC hIMC,             
	LPDWORD lpfdwConversion,   
	LPDWORD lpfdwSentence  
); 

HWND ImmGetDefaultIMEWnd(HWND hWnd ); 

BOOL ImmGetOpenStatus(
	HIMC hIMC  
); 

BOOL ImmReleaseContext(
	HWND hWnd,
	HIMC hIMC
); 

BOOL ImmSetCompositionFontA(
	HIMC hIMC,
	LOGFONTA* lplf
); 

BOOL ImmSetCompositionFontW(
	HIMC hIMC,
	LOGFONTW* lplf
); 

BOOL ImmSetCompositionWindow(
	HIMC hIMC,
	LPCOMPOSITIONFORM lpCompForm
); 

BOOL ImmSetConversionStatus(
	HIMC hIMC,             
	DWORD fdwConversion,   
	DWORD fdwSentence      
); 

BOOL ImmSetOpenStatus(
	HIMC hIMC,  
	BOOL fOpen  
); 

BOOL InitCommonControlsEx(
    LPINITCOMMONCONTROLSEX lpInitCtrls
); 

HMONITOR MonitorFromWindow(
	HWND hwnd,       // handle to a window
	DWORD dwFlags    // flags if no monitor intersects the window
); 

DWORD MsgWaitForMultipleObjectsEx(
	DWORD nCount,          // number of handles in handle array
	LPHANDLE pHandles,     // pointer to an object-handle array
	DWORD dwMilliseconds,  // time-out interval in milliseconds
	DWORD dwWakeMask,      // type of input events to wait for
	DWORD dwFlags          // wait flags
); 

void NotifyWinEvent(
	DWORD event,
	HWND hwnd,
	LONG idObject,
	LONG idChild
); 

// basic
void RtlMoveMemory(void* Destination, void* Source, DWORD Length);
// extends
void RtlMoveMemory(int Destination, void* Source, DWORD Length);
void RtlMoveMemory(void* Destination, int Source, DWORD Length);
void RtlMoveMemory(int Destination, int Source, DWORD Length);

LPITEMIDLIST SHBrowseForFolderA(          
	BROWSEINFOA* lpbi
); 

HRESULT SHGetMalloc(          
//	LPMALLOC *ppMalloc
	LPVOID	 *ppMalloc
); 

BOOL SHGetPathFromIDListA(          
	LPCITEMIDLIST pidl,
    LPSTR pszPath
); 

HRESULT ScriptBreak( 
  WCHAR *pwcChars, 
  int cChars, 
  SCRIPT_ANALYSIS *psa, 
  SCRIPT_LOGATTR *psla 
); 

HRESULT ScriptCPtoX( 
  int iCP, 
  BOOL fTrailing, 
  int cChars, 
  int cGlyphs, 
  WORD *pwLogClust, 
  SCRIPT_VISATTR *psva, 
  int *piAdvance, 
  SCRIPT_ANALYSIS *psa, 
  int *piX 
); 

HRESULT ScriptCacheGetHeight(
  HDC hdc, 
  SCRIPT_CACHE *psc, 
  long *tmHeight 
); 

HRESULT ScriptFreeCache(
  SCRIPT_CACHE *psc 
); 

HRESULT ScriptGetFontProperties(
  HDC hdc, 
  SCRIPT_CACHE *psc, 
  SCRIPT_FONTPROPERTIES *sfp 
); 

HRESULT ScriptGetLogicalWidths(
  SCRIPT_ANALYSIS *psa,
  int cChars,
  int cGlyphs,
  int *piGlyphWidth,
  WORD *pwLogClust,
  SCRIPT_VISATTR *psva,
  int *piDx
); 

HRESULT ScriptGetProperties(
  SCRIPT_PROPERTIES ***ppSp, 
  int *piNumScripts 
); 

HRESULT ScriptItemize(
  WCHAR *pwcInChars, 
  int cInChars, 
  int cMaxItems, 
  SCRIPT_CONTROL *psControl, 
  SCRIPT_STATE *psState, 
  SCRIPT_ITEM *pItems, 
  int *pcItems 
); 

HRESULT ScriptLayout(
  int cRuns, 
  BYTE *pbLevel, 
  int *piVisualToLogical, 
  int *piLogicalToVisual 
); 

HRESULT ScriptPlace(
  HDC hdc, 
  SCRIPT_CACHE *psc, 
  WORD *pwGlyphs, 
  int cGlyphs, 
  SCRIPT_VISATTR *psva, 
  SCRIPT_ANALYSIS *psa, 
  int *piAdvance, 
  GOFFSET *pGoffset, 
  ABC *pABC 
); 

HRESULT ScriptShape(
  HDC hdc, 				// in	
  SCRIPT_CACHE *psc, 	// in/out
  WCHAR *pwcChars,		//  
  int cChars, 
  int cMaxGlyphs, 
  SCRIPT_ANALYSIS *psa, 
  WORD *pwOutGlyphs, 
  WORD *pwLogClust, 
  SCRIPT_VISATTR *psva, 
  int *pcGlyphs 
); 

HRESULT ScriptTextOut(
  HDC hdc, 				// const
  SCRIPT_CACHE *psc, 
  int x, 
  int y, 
  UINT fuOptions, 
  RECT *lprc, 			// const
  SCRIPT_ANALYSIS *psa, // const
  WCHAR *pwcReserved, 	// const
  int iReserved, 
  WORD *pwGlyphs,		// 
  int cGlyphs, 
  int *piAdvance, 		// const
  int *piJustify, 		// const
  GOFFSET *pGoffset 	// const
); 

HRESULT ScriptXtoCP(
  int iX, 
  int cChars, 
  int cGlyphs, 
  WORD *pwLogClust,			// 
  SCRIPT_VISATTR *psva,		//  
  int *piAdvance, 			// 	 	
  SCRIPT_ANALYSIS *psa, 	// 
  int *piCP, 
  int *piTrailing 
); 

UINT SendInput(          
	UINT nInputs,
    LPINPUT pInputs,
    int cbSize
); 

DWORD SetLayout(
	HDC hdc,             // handle to DC
	DWORD dwLayout       // layout options
); 

BOOL SetMenuInfo(          
	HMENU hmenu,
    LPCMENUINFO lpcmi
); 

BOOL ShellExecuteExA(          
	LPSHELLEXECUTEINFOA lpExecInfo
); 

BOOL Shell_NotifyIconA( 
	DWORD dwMessage,
    PNOTIFYICONDATAA lpdata
); 

BOOL TrackMouseEvent(
	LPTRACKMOUSEEVENT lpEventTrack  // pointer to a TRACKMOUSEEVENT structure
); 
int EnumFontFamiliesW(
	HDC hdc,             // handle to device control
	LPCWSTR lpszFamily,  // pointer to family-name string
	FONTENUMPROC lpEnumFontFamProc,
				   // pointer to callback function
	LPARAM lParam        // pointer to application-supplied data
);

WINOLEAPI OleInitialize(
	LPVOID pvReserved  //Reserved; must be NULL.
);
void OleUninitialize();

DWORD CommDlgExtendedError();
HIMC ImmCreateContext();
void InitCommonControls();

}

extern (C)
{
	int wcslen(wchar* string);
}